package com.cosmoplat.xikai.business.enums;

import com.cosmoplat.xikai.common.utils.StringUtils;
import lombok.Getter;

@Getter
public enum DeviceParamsEnum {

    /**
     * 0  runStatus                               设备生产
     * 1  userManagement                          用户管理
     * 2  remainingNumberOfSmallWashers           小垫圈剩余数量
     * 3  remainingNumberOfLargeWashers           密封圈剩余数量
     * 4  remainingNumberOfCirclipSprings         大垫圈剩余数量
     * 5  BearingSurplus                          轴承剩余数量
     * 6  energyConsumption                       能耗
     * 7  currentMaximumMoment                    绝缘轴检测当前最大力矩
     * 8  setMaximumTorque                        绝缘轴检测设定最大力矩
     * 9  NumberOfPartsConsumed                   已消耗零部件数量(套)
     * 10 QualifiedQuantity                       检测合格成品数量
     * 11 UnqualifiedQuantity                     检测不合格数量
     * 12 BarCode                                 一维码/二维码
     * 13 maximumWorkingMoment1                   1#压机工作最大力矩
     * 14 setMaximumWorkingMoment1                1#压机工作设定最大力矩
     * 15 maximumWorkingMoment2                   2#压机工作最大力矩
     * 16 setMaximumWorkingMoment2                2#压机工作设定最大力矩
     * 17 tricolourLight                          三色灯
     * 18 loadingQuantity                         上料数量(法兰)
     * 19 quantityOfInsulatedShaftLoading         上料数量-绝缘轴
     * 20 TYPE_OF_TASK                            生产任务下发-种类
     * 21 numberOfTasks                           生产任务-数量
     **/
    RUN_STATE("0", "runStatus"),
    USER_MANAGEMENT("1", "userManagement"),
    REMAINGING_NUMBER_OF_SMALL_WASHERS("2", "remainingNumberOfSmallWashers"),
    REMAINING_NUMBER_OF_LARGEWASHERS("3", "remainingNumberOfLargeWashers"),
    REMAINING_NUMBER_OF_CLICLIP_SPRINGS("4", "remainingNumberOfCirclipSprings"),
    BEARING_SURPLUS("5", "BearingSurplus"),
    ENERGY_CONSUMPTION("6", "energyConsumption"),
    CURRENT_MAXIMUM_MOMENT("7", "currentMaximumMoment"),
    SET_MAXIMUM_TORQUE("8", "setMaximumTorque"),
    NUMBER_OF_PARTS_CONSUMED("9", "NumberOfPartsConsumed"),
    QUALIFIED_QUANTITY("10", "QualifiedQuantity"),
    UNQUALIFIED_QUANTITY("11", "UnqualifiedQuantity"),
    BAR_CODE("12", "BarCode"),
    MAXIMUM_WORKING_MONMENT1("13", "maximumWorkingMoment1"),
    SET_MAXIMUM_WORKING_MONMENT1("14", "setMaximumWorkingMoment1"),
    MAXIMUM_WORKING_MONMENT2("15", "maximumWorkingMoment2"),
    SET_MAXIMUM_WORKING_MONMENT2("16", "setMaximumWorkingMoment2"),
    TRICOLOUR_LIGHT("17", "tricolourLight"),
    LOADING_QUANTITY("18", "loadingQuantity"),
    QUANTITY_OF_INSULATED_SHAFT_LOADING("19", "quantityOfInsulatedShaftLoading"),
    TYPE_OF_TASK("20", "typeOfTask"),
    NUMBER_OF_TASKS("21", "numberOfTasks"),
    BARCODE_SCANNER("22", "barcodeScanner"),
    // 允许agv小车进入  40048 点位为1的时候，设备暂停，允许agv小车进入，其他情况点位为0，不允许进入
    AGV_ALLOW_IN("23", "agvAllowIn"),
    // AGV 小车已经离开， 40246 轴封服务点位写1，告知PLC可以PLC小车已经离开，可以继续生产
    AGV_ALLOW_OUT("24", "agvAllowOut"),
    ;

    private String code;
    private String name;

    DeviceParamsEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getCodeByName(String name) {
        if (StringUtils.isBlank(name)) {
            return null;
        }
        for (DeviceParamsEnum value : values()) {
            if (value.getName().equals(name)) {
                return value.getCode();
            }
        }
        return null;
    }

}
